import { reqCategoryList, reqGetBannerList, reqGetFloorList } from "@/api";

const state = {
    categoryList: [],
    bannerList: [],
    floorList: [],
};
const mutations = {
    // 三级联动
    GATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList.slice(0, 16)
    },
    // 轮播图
    GATBANNERLIST(state, bannerList) {
        state.bannerList = bannerList
    },

    GATFLOORLIST(state, floorList) {
        state.floorList = floorList
    }
};
const actions = {
    // 三级联动
    async getCategoryList({ commit }) {
        let result = await reqCategoryList();
        if (result.code === 200) {
            commit("GATEGORYLIST", result.data)
        }
    },
    // 轮播图
    async getBannerList({ commit }) {
        let result = await reqGetBannerList();
        if (result.code === 200) {
            commit("GATBANNERLIST", result.data)
        }
    },

    async getFloorList({ commit }) {
        let result = await reqGetFloorList();
        if (result.code === 200) {
            commit("GATFLOORLIST", result.data)
        }
    }
};
const getters = {};

export default {
    state, mutations, actions, getters
}